/////////////////////////////////////////////////////////////////////////////
// Name:        pkgmgrapp.cpp
// Purpose:     
// Author:      yospaly
// Modified by: 
// Created:     11/12/2008 23:24:43
// RCS-ID:      
// Copyright:   Copyright (C) 2008, yospaly
// Licence:     
/////////////////////////////////////////////////////////////////////////////

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

////@begin includes
////@end includes

#include "pkgmgrapp.h"

#include <wx/filesys.h>
#include <wx/fs_inet.h>
#include <wx/snglinst.h>

////@begin XPM images
////@end XPM images


/*!
 * Application instance implementation
 */

////@begin implement app
IMPLEMENT_APP( PkgMgrApp )
////@end implement app


/*!
 * PkgMgrApp type definition
 */

IMPLEMENT_CLASS( PkgMgrApp, wxApp )


/*!
 * PkgMgrApp event table definition
 */

BEGIN_EVENT_TABLE( PkgMgrApp, wxApp )

////@begin PkgMgrApp event table entries
////@end PkgMgrApp event table entries

END_EVENT_TABLE()


/*!
 * Constructor for PkgMgrApp
 */

PkgMgrApp::PkgMgrApp()
{
    Init();
}


/*!
 * Member initialisation
 */

void PkgMgrApp::Init()
{
////@begin PkgMgrApp member initialisation
////@end PkgMgrApp member initialisation
}

/*!
 * Initialisation for PkgMgrApp
 */

bool PkgMgrApp::OnInit()
{
    const wxString& name = wxString::Format(_T("Citrus-%s (http://citrus.googlecode.com)"), wxGetUserId().c_str());
    _checker = new wxSingleInstanceChecker(name);
    if ( _checker->IsAnotherRunning() )
    {
        // wxLogError(_("Another program instance is already running, aborting."));
        wxMessageBox(_("Citrus is already running, aborting."), _("Citrus"),
    			wxOK|wxICON_EXCLAMATION );
        return false;
    }
    
////@begin PkgMgrApp initialisation
	// Remove the comment markers above and below this block
	// to make permanent changes to the code.

#if wxUSE_XPM
	wxImage::AddHandler(new wxXPMHandler);
#endif
#if wxUSE_LIBPNG
	wxImage::AddHandler(new wxPNGHandler);
#endif
#if wxUSE_LIBJPEG
	wxImage::AddHandler(new wxJPEGHandler);
#endif
#if wxUSE_GIF
	wxImage::AddHandler(new wxGIFHandler);
#endif
	MainFrame* mainWindow = new MainFrame( NULL );
	mainWindow->Show(true);
////@end PkgMgrApp initialisation
    
	wxFileSystem::AddHandler(new wxInternetFSHandler);
	
    return true;
}


/*!
 * Cleanup for PkgMgrApp
 */

int PkgMgrApp::OnExit()
{
	delete _checker;
////@begin PkgMgrApp cleanup
	return wxApp::OnExit();
////@end PkgMgrApp cleanup
}

